#include <stdio.h>
#include <stdlib.h>

typedef struct Node Node;
struct Node {
  int data;
  Node *next;
};
int main(int argc, char *argv[]) {
  /* malloc函数
   */
  int *p = (int *)malloc(sizeof(int));
  *p = 100;
  printf("%d\n", *p);
  free(p);
  int *q = (int *)malloc(sizeof(int) * 10);
  for (int i = 0; i < 10; i++) {
    *(q + i) = i;
  }
  for (int i = 0; i < 10; i++) {
    printf("%d\t", *(q + i));
  }
  printf("\n");
  free(q);
  Node *pNode;
  pNode = (Node *)malloc(sizeof(Node));
  if (pNode == NULL) {
    printf("内存分配失败！");
    return -1;
  }
  pNode->data = 30;
  pNode->next = NULL;
  printf("%d\n", pNode->data);
  free(pNode);
  return EXIT_SUCCESS;
}
